<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hello world</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/angular.js"></script>

</head>
<body>

    <div ng-app="firstApp">
        <div id="div01" ng-controller="myCtrl1">
            <input type="text" ng-model="person.userName">
            <p>这是DIV01的内容</p>
            <p ng-bind="person.userName"></p>
            <div id="div02" ng-controller="myCtrl2">

                <p>
                    这里DIV02的内容：
                </p>
                <input type="text" ng-model="person.userName">
                <p>name:{{person.userName}}</p>
            </div>
        </div>

    </div>


    <script>
        var app = angular.module('firstApp', []);
        app.run(function ($rootScope) {
            $rootScope.userName='404';
        })
        app.controller('myCtrl1',['$scope','$rootScope',function(s1,r) {

            s1.person={"userName":"div01..."};
            console.log(angular.element('#div01').scope()==s1);

        }]);
        app.controller('myCtrl2',['$scope',function(s2) {

//            s2.userName='div02....'
            s2.person.userName='hahaha';
//            s.userName='div01_user';
//            s.userId='00008';
//
//            var ngInjector = angular.injector(['ng']);
//
//            console.log("ng $rootScope=" + ngInjector.has("$rootScope"));//true
//
//            console.log(app);//true
        }]);


    </script>
</body>
</html>